package com.rui.study.algorithm.T_Enum的JSON;

import lombok.Getter;
import org.codehaus.jackson.annotate.JsonValue;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: study_20180903
 * @description:
 * @author: Yaowr
 * @create: 2018-10-24 18:09
 **/
@Getter
public enum  Scenario {
    REGISTER(1, "用户注册"),
    TWO_FACTOR_LOGIN(2, "双因子登录");

    private int code;
    private String desc;

    Scenario(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @JsonValue
    public Map<String, Object> toMap() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", this.name());
        map.put("code", this.getCode());
        map.put("desc", this.getDesc());
        return map;
    }
}
